#include <rtl/base.h>
#include "io.h"

#define TIMEOUT 0x3FFF

VOID ResetBoard();
VOID AgEnterBootROM()
{
    UINT32 Reg = ((TIMEOUT << 2) & 0xFFFC) | 1;

    WRITE32(0x10001838, 0xAD98);
    WRITE32(0x10001840, READ32(0x10001840) | 1);
    WRITE32(0x10001838, 0);
    WRITE32(0x10001818, Reg | 0x444C0000);

    WRITE32(0x10007008, 0x1971);
    WRITE32(0x10007000, (READ32(0x10007000) & 0xFFFFFFB7) | 0x22000004);
    for (int i = 0; i < 500; i++)
    {
    }
    WRITE32(0x10007014, 0x1209);

    while (1)
        ;
}